
% 根据调度方案绘制甘特图
clc;
clear;  
 A= [1	1	1	1	0	3	15	18
2	3	1	4	0	1	8	9
8	1	2	2	0	3	9	11
15	1	2	2	11	12	17	20
6	2	1	3	0	3	9	12
12	1	1	1	18	20	30	31
4	3	1	4	9	10	15	16
3	1	2	2	20	23	32	33
13	2	1	3	12	15	20	22
9	3	1	4	16	17	21	23
17	3	1	4	23	24	26	27
7	1	1	1	31	33	38	41
11	2	1	3	22	25	32	34
10	1	1	1	33	35	43	46
16	1	1	1	41	44	49	51
14	2	1	3	34	36	41	44
5	3	1	4	27	28	33	36]
schedule=A
figure;
Job=max(schedule(:,1));
Machinedis=max(schedule(:,2));
ylim([0 5]);
row=size(schedule,1);
%eachcolors=[0 0.80784 0.81961];
 eachcolors1=[0.74118 0.71765 0.41961];
%eachcolors2=[0 0.80784 0.81961];
%for i=1:row
   % X=[schedule(i,5) schedule(i,6)];
  %  now=schedule(i,4)
   % Y=[now now]
 %  line(X,Y,'LineWidth',30,'color',eachcolors);
 % line(X,Y,'LineWidth',25,'color',[0.8500 0.3250 0.0980])
%end
for i=1:row
     X=[schedule(i,6) schedule(i,7)];
    now=schedule(i,4)
     Y=[now now]
%line(X,Y,'LineWidth',25,'color',eachcolors1);
line(X,Y,'LineWidth',25,'color',[0.65,0.65,0.65])
end 
%for i=1:row
  %   X=[schedule(i,7) schedule(i,8)];
  %  now=schedule(i,4)
  %   Y=[now now]
%	line(X,Y,'LineWidth',30,'color',eachcolors2);
%line(X,Y,'LineWidth',25,'color',[0 0.4470 0.7410])
%end 
for  i=1:row
    X=schedule(i,6:7)
txt=[num2str(schedule(i,1))];
   now=schedule(i,4)
text( mean(X), now,txt,"FontName","Times New Roman","FontSize",15,"LineWidth",20)
end
yticks(1:4);
ytickTxt=cell(1,4);
ytickTxt(1)={['M' num2str(1) '-' num2str(1)] };
ytickTxt(2)={['M' num2str(1) '-' num2str(2)] };
ytickTxt(3)={['M' num2str(2)] }% '-' num2str(1)] };
ytickTxt(4)={['M' num2str(3) ] }%'-' num2str(1)] };
yticklabels( ytickTxt);
%title('The Scheduling Result')
%xlabel('Processing Time')
%ylabel('Processing Machine')
title('切割调度结果')
xlabel('加工时间')
ylabel('加工机器')